function [ vBase, nLDof, xLDof, sfun ] = sf_quad_Q5( i_eval, n_sdim, n_vert, i_dof, xi, aInvJac, vBase )
%SF_QUAD_Q5 Biquintic conforming shape function for quadrilaterals (Q5).
%
%   [ VBASE, NLDOF, XLDOF, SFUN ] = SF_QUAD_Q5( I_EVAL, N_SDIM, N_VERT, I_DOF, XI, AINVJAC, VBASE )
%   Evaluates conforming biquintic Q5 shape functions on quadrilaterals
%   with values defined in the nodes, edges, and cell center. XI is
%   [-1..1]^2 reference coordinates.
%
%       Input       Value/[Size]           Description
%       -----------------------------------------------------------------------------------
%       i_eval      scalar:  1             Evaluate function values
%                           >1             Evaluate values of derivatives
%       n_sdim      scalar:  2             Number of space dimensions
%       n_vert      scalar:  4             Number of vertices per cell
%       i_dof       scalar: 1-36           Local basis function to evaluate
%       xi          [n_sdim]               Local coordinates of evaluation point
%       aInvJac     [n,n_sdim*n_sdim]      Inverse of transformation Jacobian
%       vBase       [n]                    Preallocated output vector
%                                                                                         .
%       Output      Value/[Size]           Description
%       -----------------------------------------------------------------------------------
%       vBase       [n]                    Evaluated function values
%       nLDof       [4]                    Number of local degrees of freedom on
%                                          vertices, edges, faces, and cell interiors
%       xLDof       [n_sdim,n_ldof]        Local coordinates of local dofs
%       sfun        string                 Function name of called shape function
%
%   See also SF_QUAD_Q1

% Copyright 2013-2019 Precise Simulation, Ltd.


nLDof = [4 16 0 16];
xLDof = [-1  1 1 -1  -3/5  1   3/5 -1    -1/5  1   1/5 -1     1/5  1   -1/5 -1     3/5  1   -3/5 -1    -3/5  3/5 3/5 -3/5  -1/5  3/5 1/5 -3/5   1/5 3/5 -1/5 -3/5  -1/5  1/5 1/5 -1/5;
         -1 -1 1  1  -1   -3/5 1    3/5  -1   -1/5 1    1/5  -1    1/5  1   -1/5  -1    3/5  1   -3/5  -3/5 -3/5 3/5  3/5  -3/5 -1/5 3/5  1/5  -3/5 1/5  3/5 -1/5  -1/5 -1/5 1/5  1/5];
sfun  = 'sf_quad_Q5';


switch i_eval

  case 1

    switch i_dof
      case 1
        vBase = ((625*xi(1)^5)/768 - (625*xi(1)^4)/768 - (125*xi(1)^3)/384 + (125*xi(1)^2)/384 + (3*xi(1))/256 - 3/256)*((625*xi(2)^5)/768 - (625*xi(2)^4)/768 - (125*xi(2)^3)/384 + (125*xi(2)^2)/384 + (3*xi(2))/256 - 3/256);
      case 2
        vBase = -((625*xi(1)^5)/768 + (625*xi(1)^4)/768 - (125*xi(1)^3)/384 - (125*xi(1)^2)/384 + (3*xi(1))/256 + 3/256)*((625*xi(2)^5)/768 - (625*xi(2)^4)/768 - (125*xi(2)^3)/384 + (125*xi(2)^2)/384 + (3*xi(2))/256 - 3/256);
      case 3
        vBase = ((625*xi(1)^5)/768 + (625*xi(1)^4)/768 - (125*xi(1)^3)/384 - (125*xi(1)^2)/384 + (3*xi(1))/256 + 3/256)*((625*xi(2)^5)/768 + (625*xi(2)^4)/768 - (125*xi(2)^3)/384 - (125*xi(2)^2)/384 + (3*xi(2))/256 + 3/256);
      case 4
        vBase = -((625*xi(1)^5)/768 - (625*xi(1)^4)/768 - (125*xi(1)^3)/384 + (125*xi(1)^2)/384 + (3*xi(1))/256 - 3/256)*((625*xi(2)^5)/768 + (625*xi(2)^4)/768 - (125*xi(2)^3)/384 - (125*xi(2)^2)/384 + (3*xi(2))/256 + 3/256);
      case 5
        vBase = -((625*xi(2)^5)/768 - (625*xi(2)^4)/768 - (125*xi(2)^3)/384 + (125*xi(2)^2)/384 + (3*xi(2))/256 - 3/256)*((3125*xi(1)^5)/768 - (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 + (325*xi(1)^2)/128 + (125*xi(1))/768 - 25/256);
      case 6
        vBase = ((625*xi(1)^5)/768 + (625*xi(1)^4)/768 - (125*xi(1)^3)/384 - (125*xi(1)^2)/384 + (3*xi(1))/256 + 3/256)*((3125*xi(2)^5)/768 - (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 + (325*xi(2)^2)/128 + (125*xi(2))/768 - 25/256);
      case 7
        vBase = -((625*xi(2)^5)/768 + (625*xi(2)^4)/768 - (125*xi(2)^3)/384 - (125*xi(2)^2)/384 + (3*xi(2))/256 + 3/256)*((3125*xi(1)^5)/768 + (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 - (325*xi(1)^2)/128 + (125*xi(1))/768 + 25/256);
      case 8
        vBase = ((625*xi(1)^5)/768 - (625*xi(1)^4)/768 - (125*xi(1)^3)/384 + (125*xi(1)^2)/384 + (3*xi(1))/256 - 3/256)*((3125*xi(2)^5)/768 + (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 - (325*xi(2)^2)/128 + (125*xi(2))/768 + 25/256);
      case 9
        vBase = ((625*xi(2)^5)/768 - (625*xi(2)^4)/768 - (125*xi(2)^3)/384 + (125*xi(2)^2)/384 + (3*xi(2))/256 - 3/256)*((3125*xi(1)^5)/384 - (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 + (425*xi(1)^2)/192 + (375*xi(1))/128 - 75/128);
      case 10
        vBase = -((625*xi(1)^5)/768 + (625*xi(1)^4)/768 - (125*xi(1)^3)/384 - (125*xi(1)^2)/384 + (3*xi(1))/256 + 3/256)*((3125*xi(2)^5)/384 - (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 + (425*xi(2)^2)/192 + (375*xi(2))/128 - 75/128);
      case 11
        vBase = ((625*xi(2)^5)/768 + (625*xi(2)^4)/768 - (125*xi(2)^3)/384 - (125*xi(2)^2)/384 + (3*xi(2))/256 + 3/256)*((3125*xi(1)^5)/384 + (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 - (425*xi(1)^2)/192 + (375*xi(1))/128 + 75/128);
      case 12
        vBase = -((625*xi(1)^5)/768 - (625*xi(1)^4)/768 - (125*xi(1)^3)/384 + (125*xi(1)^2)/384 + (3*xi(1))/256 - 3/256)*((3125*xi(2)^5)/384 + (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 - (425*xi(2)^2)/192 + (375*xi(2))/128 + 75/128);
      case 13
        vBase = -((625*xi(2)^5)/768 - (625*xi(2)^4)/768 - (125*xi(2)^3)/384 + (125*xi(2)^2)/384 + (3*xi(2))/256 - 3/256)*((3125*xi(1)^5)/384 + (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 - (425*xi(1)^2)/192 + (375*xi(1))/128 + 75/128);
      case 14
        vBase = ((625*xi(1)^5)/768 + (625*xi(1)^4)/768 - (125*xi(1)^3)/384 - (125*xi(1)^2)/384 + (3*xi(1))/256 + 3/256)*((3125*xi(2)^5)/384 + (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 - (425*xi(2)^2)/192 + (375*xi(2))/128 + 75/128);
      case 15
        vBase = -((625*xi(2)^5)/768 + (625*xi(2)^4)/768 - (125*xi(2)^3)/384 - (125*xi(2)^2)/384 + (3*xi(2))/256 + 3/256)*((3125*xi(1)^5)/384 - (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 + (425*xi(1)^2)/192 + (375*xi(1))/128 - 75/128);
      case 16
        vBase = ((625*xi(1)^5)/768 - (625*xi(1)^4)/768 - (125*xi(1)^3)/384 + (125*xi(1)^2)/384 + (3*xi(1))/256 - 3/256)*((3125*xi(2)^5)/384 - (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 + (425*xi(2)^2)/192 + (375*xi(2))/128 - 75/128);
      case 17
        vBase = ((625*xi(2)^5)/768 - (625*xi(2)^4)/768 - (125*xi(2)^3)/384 + (125*xi(2)^2)/384 + (3*xi(2))/256 - 3/256)*((3125*xi(1)^5)/768 + (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 - (325*xi(1)^2)/128 + (125*xi(1))/768 + 25/256);
      case 18
        vBase = -((625*xi(1)^5)/768 + (625*xi(1)^4)/768 - (125*xi(1)^3)/384 - (125*xi(1)^2)/384 + (3*xi(1))/256 + 3/256)*((3125*xi(2)^5)/768 + (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 - (325*xi(2)^2)/128 + (125*xi(2))/768 + 25/256);
      case 19
        vBase = ((625*xi(2)^5)/768 + (625*xi(2)^4)/768 - (125*xi(2)^3)/384 - (125*xi(2)^2)/384 + (3*xi(2))/256 + 3/256)*((3125*xi(1)^5)/768 - (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 + (325*xi(1)^2)/128 + (125*xi(1))/768 - 25/256);
      case 20
        vBase = -((625*xi(1)^5)/768 - (625*xi(1)^4)/768 - (125*xi(1)^3)/384 + (125*xi(1)^2)/384 + (3*xi(1))/256 - 3/256)*((3125*xi(2)^5)/768 - (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 + (325*xi(2)^2)/128 + (125*xi(2))/768 - 25/256);
      case 21
        vBase = ((3125*xi(1)^5)/768 - (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 + (325*xi(1)^2)/128 + (125*xi(1))/768 - 25/256)*((3125*xi(2)^5)/768 - (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 + (325*xi(2)^2)/128 + (125*xi(2))/768 - 25/256);
      case 22
        vBase = -((3125*xi(1)^5)/768 + (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 - (325*xi(1)^2)/128 + (125*xi(1))/768 + 25/256)*((3125*xi(2)^5)/768 - (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 + (325*xi(2)^2)/128 + (125*xi(2))/768 - 25/256);
      case 23
        vBase = ((3125*xi(1)^5)/768 + (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 - (325*xi(1)^2)/128 + (125*xi(1))/768 + 25/256)*((3125*xi(2)^5)/768 + (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 - (325*xi(2)^2)/128 + (125*xi(2))/768 + 25/256);
      case 24
        vBase = -((3125*xi(1)^5)/768 - (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 + (325*xi(1)^2)/128 + (125*xi(1))/768 - 25/256)*((3125*xi(2)^5)/768 + (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 - (325*xi(2)^2)/128 + (125*xi(2))/768 + 25/256);
      case 25
        vBase = -((3125*xi(1)^5)/384 - (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 + (425*xi(1)^2)/192 + (375*xi(1))/128 - 75/128)*((3125*xi(2)^5)/768 - (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 + (325*xi(2)^2)/128 + (125*xi(2))/768 - 25/256);
      case 26
        vBase = ((3125*xi(1)^5)/768 + (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 - (325*xi(1)^2)/128 + (125*xi(1))/768 + 25/256)*((3125*xi(2)^5)/384 - (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 + (425*xi(2)^2)/192 + (375*xi(2))/128 - 75/128);
      case 27
        vBase = -((3125*xi(1)^5)/384 + (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 - (425*xi(1)^2)/192 + (375*xi(1))/128 + 75/128)*((3125*xi(2)^5)/768 + (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 - (325*xi(2)^2)/128 + (125*xi(2))/768 + 25/256);
      case 28
        vBase = ((3125*xi(1)^5)/768 - (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 + (325*xi(1)^2)/128 + (125*xi(1))/768 - 25/256)*((3125*xi(2)^5)/384 + (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 - (425*xi(2)^2)/192 + (375*xi(2))/128 + 75/128);
      case 29
        vBase = ((3125*xi(1)^5)/384 + (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 - (425*xi(1)^2)/192 + (375*xi(1))/128 + 75/128)*((3125*xi(2)^5)/768 - (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 + (325*xi(2)^2)/128 + (125*xi(2))/768 - 25/256);
      case 30
        vBase = -((3125*xi(1)^5)/768 + (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 - (325*xi(1)^2)/128 + (125*xi(1))/768 + 25/256)*((3125*xi(2)^5)/384 + (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 - (425*xi(2)^2)/192 + (375*xi(2))/128 + 75/128);
      case 31
        vBase = ((3125*xi(1)^5)/384 - (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 + (425*xi(1)^2)/192 + (375*xi(1))/128 - 75/128)*((3125*xi(2)^5)/768 + (625*xi(2)^4)/256 - (1625*xi(2)^3)/384 - (325*xi(2)^2)/128 + (125*xi(2))/768 + 25/256);
      case 32
        vBase = -((3125*xi(1)^5)/768 - (625*xi(1)^4)/256 - (1625*xi(1)^3)/384 + (325*xi(1)^2)/128 + (125*xi(1))/768 - 25/256)*((3125*xi(2)^5)/384 - (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 + (425*xi(2)^2)/192 + (375*xi(2))/128 - 75/128);
      case 33
        vBase = ((3125*xi(1)^5)/384 - (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 + (425*xi(1)^2)/192 + (375*xi(1))/128 - 75/128)*((3125*xi(2)^5)/384 - (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 + (425*xi(2)^2)/192 + (375*xi(2))/128 - 75/128);
      case 34
        vBase = -((3125*xi(1)^5)/384 + (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 - (425*xi(1)^2)/192 + (375*xi(1))/128 + 75/128)*((3125*xi(2)^5)/384 - (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 + (425*xi(2)^2)/192 + (375*xi(2))/128 - 75/128);
      case 35
        vBase = ((3125*xi(1)^5)/384 + (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 - (425*xi(1)^2)/192 + (375*xi(1))/128 + 75/128)*((3125*xi(2)^5)/384 + (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 - (425*xi(2)^2)/192 + (375*xi(2))/128 + 75/128);
      case 36
        vBase = -((3125*xi(1)^5)/384 - (625*xi(1)^4)/384 - (2125*xi(1)^3)/192 + (425*xi(1)^2)/192 + (375*xi(1))/128 - 75/128)*((3125*xi(2)^5)/384 + (625*xi(2)^4)/384 - (2125*xi(2)^3)/192 - (425*xi(2)^2)/192 + (375*xi(2))/128 + 75/128);
    end

  case {2,3}

    switch i_dof
      case 1
        dNdxi1 = ((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*((3125*xi(1)^4)/768 - (625*xi(1)^3)/192 - (125*xi(1)^2)/128 + (125*xi(1))/192 + 3/256))/768;
        dNdxi2 = ((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*((3125*xi(2)^4)/768 - (625*xi(2)^3)/192 - (125*xi(2)^2)/128 + (125*xi(2))/192 + 3/256))/768;
      case 2
        dNdxi1 = -((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*((3125*xi(1)^4)/768 + (625*xi(1)^3)/192 - (125*xi(1)^2)/128 - (125*xi(1))/192 + 3/256))/768;
        dNdxi2 = -((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) + 1)*((3125*xi(2)^4)/768 - (625*xi(2)^3)/192 - (125*xi(2)^2)/128 + (125*xi(2))/192 + 3/256))/768;
      case 3
        dNdxi1 = ((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) + 1)*((3125*xi(1)^4)/768 + (625*xi(1)^3)/192 - (125*xi(1)^2)/128 - (125*xi(1))/192 + 3/256))/768;
        dNdxi2 = ((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) + 1)*((3125*xi(2)^4)/768 + (625*xi(2)^3)/192 - (125*xi(2)^2)/128 - (125*xi(2))/192 + 3/256))/768;
      case 4
        dNdxi1 = -((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) + 1)*((3125*xi(1)^4)/768 - (625*xi(1)^3)/192 - (125*xi(1)^2)/128 + (125*xi(1))/192 + 3/256))/768;
        dNdxi2 = -((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*((3125*xi(2)^4)/768 + (625*xi(2)^3)/192 - (125*xi(2)^2)/128 - (125*xi(2))/192 + 3/256))/768;
      case 5
        dNdxi1 = -((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*((15625*xi(1)^4)/768 - (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 + (325*xi(1))/64 + 125/768))/768;
        dNdxi2 = -(25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(xi(1) - 1)*(xi(1) + 1)*((3125*xi(2)^4)/768 - (625*xi(2)^3)/192 - (125*xi(2)^2)/128 + (125*xi(2))/192 + 3/256))/768;
      case 6
        dNdxi1 = (25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(xi(2) - 1)*(xi(2) + 1)*((3125*xi(1)^4)/768 + (625*xi(1)^3)/192 - (125*xi(1)^2)/128 - (125*xi(1))/192 + 3/256))/768;
        dNdxi2 = ((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) + 1)*((15625*xi(2)^4)/768 - (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 + (325*xi(2))/64 + 125/768))/768;
      case 7
        dNdxi1 = -((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) + 1)*((15625*xi(1)^4)/768 + (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 - (325*xi(1))/64 + 125/768))/768;
        dNdxi2 = -(25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((3125*xi(2)^4)/768 + (625*xi(2)^3)/192 - (125*xi(2)^2)/128 - (125*xi(2))/192 + 3/256))/768;
      case 8
        dNdxi1 = (25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((3125*xi(1)^4)/768 - (625*xi(1)^3)/192 - (125*xi(1)^2)/128 + (125*xi(1))/192 + 3/256))/768;
        dNdxi2 = ((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*((15625*xi(2)^4)/768 + (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 - (325*xi(2))/64 + 125/768))/768;
      case 9
        dNdxi1 = ((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*((15625*xi(1)^4)/384 - (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 + (425*xi(1))/96 + 375/128))/768;
        dNdxi2 = (25*(5*xi(1) - 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((3125*xi(2)^4)/768 - (625*xi(2)^3)/192 - (125*xi(2)^2)/128 + (125*xi(2))/192 + 3/256))/384;
      case 10
        dNdxi1 = -(25*(5*xi(2) - 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((3125*xi(1)^4)/768 + (625*xi(1)^3)/192 - (125*xi(1)^2)/128 - (125*xi(1))/192 + 3/256))/384;
        dNdxi2 = -((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) + 1)*((15625*xi(2)^4)/384 - (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 + (425*xi(2))/96 + 375/128))/768;
      case 11
        dNdxi1 = ((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) + 1)*((15625*xi(1)^4)/384 + (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 - (425*xi(1))/96 + 375/128))/768;
        dNdxi2 = (25*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((3125*xi(2)^4)/768 + (625*xi(2)^3)/192 - (125*xi(2)^2)/128 - (125*xi(2))/192 + 3/256))/384;
      case 12
        dNdxi1 = -(25*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((3125*xi(1)^4)/768 - (625*xi(1)^3)/192 - (125*xi(1)^2)/128 + (125*xi(1))/192 + 3/256))/384;
        dNdxi2 = -((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*((15625*xi(2)^4)/384 + (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 - (425*xi(2))/96 + 375/128))/768;
      case 13
        dNdxi1 = -((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*((15625*xi(1)^4)/384 + (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 - (425*xi(1))/96 + 375/128))/768;
        dNdxi2 = -(25*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((3125*xi(2)^4)/768 - (625*xi(2)^3)/192 - (125*xi(2)^2)/128 + (125*xi(2))/192 + 3/256))/384;
      case 14
        dNdxi1 = (25*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((3125*xi(1)^4)/768 + (625*xi(1)^3)/192 - (125*xi(1)^2)/128 - (125*xi(1))/192 + 3/256))/384;
        dNdxi2 = ((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) + 1)*((15625*xi(2)^4)/384 + (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 - (425*xi(2))/96 + 375/128))/768;
      case 15
        dNdxi1 = -((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) + 1)*((15625*xi(1)^4)/384 - (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 + (425*xi(1))/96 + 375/128))/768;
        dNdxi2 = -(25*(5*xi(1) - 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((3125*xi(2)^4)/768 + (625*xi(2)^3)/192 - (125*xi(2)^2)/128 - (125*xi(2))/192 + 3/256))/384;
      case 16
        dNdxi1 = (25*(5*xi(2) - 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((3125*xi(1)^4)/768 - (625*xi(1)^3)/192 - (125*xi(1)^2)/128 + (125*xi(1))/192 + 3/256))/384;
        dNdxi2 = ((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*((15625*xi(2)^4)/384 - (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 + (425*xi(2))/96 + 375/128))/768;
      case 17
        dNdxi1 = ((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*((15625*xi(1)^4)/768 + (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 - (325*xi(1))/64 + 125/768))/768;
        dNdxi2 = (25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((3125*xi(2)^4)/768 - (625*xi(2)^3)/192 - (125*xi(2)^2)/128 + (125*xi(2))/192 + 3/256))/768;
      case 18
        dNdxi1 = -(25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((3125*xi(1)^4)/768 + (625*xi(1)^3)/192 - (125*xi(1)^2)/128 - (125*xi(1))/192 + 3/256))/768;
        dNdxi2 = -((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) + 1)*((15625*xi(2)^4)/768 + (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 - (325*xi(2))/64 + 125/768))/768;
      case 19
        dNdxi1 = ((5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) + 1)*((15625*xi(1)^4)/768 - (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 + (325*xi(1))/64 + 125/768))/768;
        dNdxi2 = (25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(xi(1) - 1)*(xi(1) + 1)*((3125*xi(2)^4)/768 + (625*xi(2)^3)/192 - (125*xi(2)^2)/128 - (125*xi(2))/192 + 3/256))/768;
      case 20
        dNdxi1 = -(25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(xi(2) - 1)*(xi(2) + 1)*((3125*xi(1)^4)/768 - (625*xi(1)^3)/192 - (125*xi(1)^2)/128 + (125*xi(1))/192 + 3/256))/768;
        dNdxi2 = -((5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*((15625*xi(2)^4)/768 - (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 + (325*xi(2))/64 + 125/768))/768;
      case 21
        dNdxi1 = (25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/768 - (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 + (325*xi(1))/64 + 125/768))/768;
        dNdxi2 = (25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/768 - (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 + (325*xi(2))/64 + 125/768))/768;
      case 22
        dNdxi1 = -(25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/768 + (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 - (325*xi(1))/64 + 125/768))/768;
        dNdxi2 = -(25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/768 - (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 + (325*xi(2))/64 + 125/768))/768;
      case 23
        dNdxi1 = (25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/768 + (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 - (325*xi(1))/64 + 125/768))/768;
        dNdxi2 = (25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/768 + (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 - (325*xi(2))/64 + 125/768))/768;
      case 24
        dNdxi1 = -(25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/768 - (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 + (325*xi(1))/64 + 125/768))/768;
        dNdxi2 = -(25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/768 + (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 - (325*xi(2))/64 + 125/768))/768;
      case 25
        dNdxi1 = -(25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/384 - (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 + (425*xi(1))/96 + 375/128))/768;
        dNdxi2 = -(25*(5*xi(1) - 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/768 - (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 + (325*xi(2))/64 + 125/768))/384;
      case 26
        dNdxi1 = (25*(5*xi(2) - 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/768 + (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 - (325*xi(1))/64 + 125/768))/384;
        dNdxi2 = (25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/384 - (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 + (425*xi(2))/96 + 375/128))/768;
      case 27
        dNdxi1 = -(25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/384 + (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 - (425*xi(1))/96 + 375/128))/768;
        dNdxi2 = -(25*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/768 + (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 - (325*xi(2))/64 + 125/768))/384;
      case 28
        dNdxi1 = (25*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/768 - (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 + (325*xi(1))/64 + 125/768))/384;
        dNdxi2 = (25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/384 + (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 - (425*xi(2))/96 + 375/128))/768;
      case 29
        dNdxi1 = (25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) - 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/384 + (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 - (425*xi(1))/96 + 375/128))/768;
        dNdxi2 = (25*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/768 - (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 + (325*xi(2))/64 + 125/768))/384;
      case 30
        dNdxi1 = -(25*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/768 + (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 - (325*xi(1))/64 + 125/768))/384;
        dNdxi2 = -(25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/384 + (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 - (425*xi(2))/96 + 375/128))/768;
      case 31
        dNdxi1 = (25*(5*xi(2) - 1)*(5*xi(2) + 1)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/384 - (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 + (425*xi(1))/96 + 375/128))/768;
        dNdxi2 = (25*(5*xi(1) - 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/768 + (625*xi(2)^3)/64 - (1625*xi(2)^2)/128 - (325*xi(2))/64 + 125/768))/384;
      case 32
        dNdxi1 = -(25*(5*xi(2) - 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/768 - (625*xi(1)^3)/64 - (1625*xi(1)^2)/128 + (325*xi(1))/64 + 125/768))/384;
        dNdxi2 = -(25*(5*xi(1) - 1)*(5*xi(1) + 1)*(5*xi(1) - 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/384 - (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 + (425*xi(2))/96 + 375/128))/768;
      case 33
        dNdxi1 = (25*(5*xi(2) - 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/384 - (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 + (425*xi(1))/96 + 375/128))/384;
        dNdxi2 = (25*(5*xi(1) - 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/384 - (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 + (425*xi(2))/96 + 375/128))/384;
      case 34
        dNdxi1 = -(25*(5*xi(2) - 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/384 + (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 - (425*xi(1))/96 + 375/128))/384;
        dNdxi2 = -(25*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/384 - (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 + (425*xi(2))/96 + 375/128))/384;
      case 35
        dNdxi1 = (25*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/384 + (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 - (425*xi(1))/96 + 375/128))/384;
        dNdxi2 = (25*(5*xi(1) + 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/384 + (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 - (425*xi(2))/96 + 375/128))/384;
      case 36
        dNdxi1 = -(25*(5*xi(2) + 1)*(5*xi(2) - 3)*(5*xi(2) + 3)*(xi(2) - 1)*(xi(2) + 1)*((15625*xi(1)^4)/384 - (625*xi(1)^3)/96 - (2125*xi(1)^2)/64 + (425*xi(1))/96 + 375/128))/384;
        dNdxi2 = -(25*(5*xi(1) - 1)*(5*xi(1) - 3)*(5*xi(1) + 3)*(xi(1) - 1)*(xi(1) + 1)*((15625*xi(2)^4)/384 + (625*xi(2)^3)/96 - (2125*xi(2)^2)/64 - (425*xi(2))/96 + 375/128))/384;
    end

    if( i_eval==2 )
      vBase = aInvJac(:,1).*dNdxi1 + aInvJac(:,2).*dNdxi2;
    else
      vBase = aInvJac(:,3).*dNdxi1 + aInvJac(:,4).*dNdxi2;
    end

  case {22,23,32,33}   % Evaluation of second order derivatives.
    error('sf_quad_Q5: second order derivative evaluation not supported.')

  otherwise
    vBase = 0;

end
